<div class="nav-sub w1180">
	<ul class="zoom">
		<li><a class="on" href="">新增溯源类目</a></li>
		<li><a href="/crm/material/catelog-list">溯源类型列表</a></li>
		<li><a href="/crm/material/cate-list">溯源类目列表</a></li>
		<li><a href="/crm/material/list">溯源列表</a></li>
		<li><a href="/crm/material/report-list">溯源报告列表</a></li>
	</ul>
</div>
<div class="main-ct w1180">
	<a href="javascript:history.go(-1);" class="btn-cs btn-blue btn-fillet mt10">返 回</a>
	<form id="commonForm" method="post" action="/crm/material/insert-cate">
	<div class="form-info mt20">
		<dl>
			<dt>溯源分类：</dt>
			<dd>
				<select name="catelog_id" id="catelog_id">
    			<?php if ($this->catalog):?>
				<?php foreach ($this->catalog as $k=>$v):?>
    				<option value="<?php echo $v['material_catalog_id']; ?>"><?php echo $v['material_catalog_name']; ?></option>
    			<?php endforeach; ?>
    			<?php else:?>
    				<option value="">请选择</option>
				<?php endif;?>		
    			</select>
			</dd>
		</dl>
		<dl>
			<dt>溯源类目：</dt>
			<dd>
				<input type="text" class="txt" name="cate_name" id="cate_name">
			</dd>
		</dl>
	</div>
	<p class="mt30 txt-center">
			<input class="input-cs btn-fillet btn-green" type="submit" value="确定" />
			<input class="input-cs btn-fillet mr20" type="reset" value="取消" />
	</p>
	</form>	
</div>
<script type="text/javascript">
$().ready(function() {
	$("#commonForm").validate({
		debug:true,
		rules: {
			catelog_id: {
				required: true,
			},
			cate_name: {
				required: true,
			},
	
		},
		submitHandler:function(form){ 
	            form.submit();
	    }   
	});

});


    function addCatelog(){
    	var catelog_id = $("#catelog_id").val();
    	var cate_name = $("#cate_name").val();
    	var data = {'catelog_id':catelog_id, 'cate_name':cate_name};
    	$.post("/crm/material/insert-cate", data, response, 'json');
    }
    
    function response(res){
        if(res.result){
        	location.href = "/crm/material/cate-list";
        }else{
        	alert(res.reason);
        }
        
    }
</script>